package impl.controller;


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author futao
 * Created on 18-2-5-下午12:52.
 */
@Controller
public class WorldController {

    private static final Log logger = LogFactory.getLog(WorldController.class);

    @RequestMapping(
            value = "/world",
            method = RequestMethod.POST,
//            consumes = "application/json",
            produces = "application/json"
    )
    public ModelAndView world(
            HttpServletRequest httpServletRequest,
            HttpServletResponse httpServletResponse,
            @RequestParam(name = "name", required = true, defaultValue = "") String name,
            @RequestParam(name = "age", required = false) Integer age
    ) {
        logger.info("hello被调用了2");
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("message", "Hello World");
        modelAndView.setViewName("/WEB-INF/content/welcome.jsp");
        return modelAndView;
    }
}